<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>购票系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/booking2/css/font.css">
    <link rel="stylesheet" href="/booking2/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="/booking2/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/booking2/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-lg12 x-so">
            <input class="layui-hide" type="number" value="0" name="page" id="page">
          <input class="layui-input" type="number" placeholder="票ID" name="ticketId" id="ticketId" th:value="${ticketId}">
          <input class="layui-input" type="text" placeholder="票名" name="ticketName" id="ticketName" th:value="${ticketName }">
          <input class="layui-input" type="number"   placeholder="价格" name="ticketPrice" id="ticketPrice" th:value="${ticketPrice}">
            <button class="layui-btn"  href=""><i class="layui-icon">&#xe615;</i></button>
        </form>
      </div>
        <xblock>
            <button class="layui-btn" onclick="x_admin_show('添加票种','/ticket/toAddTicket')"><i class="layui-icon"></i>添加票种</button>
            <span class="x-right" style="line-height:40px" th:text="'共有票种数：'+ ${conEle}"></span>
        </xblock>

      <table class="layui-table">
        <thead>
            <th>票ID</th>
            <th>票名</th>
            <th>价格</th>
            <th>描述</th>
            <th>操作</th>
        </thead>
        <tbody>
        <tr th:each="x:${ticketsList}">
            <td th:text="${x.ticketId}"></td>
            <td th:text="${x.ticketName}"></td>
            <td th:text="${x.ticketPrice}"></td>
            <td th:text="${x.ticketDiscribe}"></td>
            <td >
                <a title="修改"  onclick="update(this)" href="javascript:;" >
                    <i class="layui-icon">&#xe642;</i>
                </a>&emsp;
                <a title="删除" onclick="deldate(this)" href="javascript:;" >
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        </tbody>
      </table>
      <div class="page">
        <div>
          <a class="prev" th:href="@{'/ticket/list?page=' + ${lastPage} + '&ticketId='+ ${ticketId!=null ? ticketId :''} + '&ticketName='+${ticketName !=null ? ticketName :''} + '&ticketPrice=' +${ticketPrice !=null ? ticketPrice :''}}">&lt;&lt;</a>
          <a class="num" href="">1</a>
          <span class="current" th:text="${nowPage}"></span>
          <a class="num"  th:text="${conPage}" th:href="@{'/ticket/list?page=' + ${conPage-1} + '&ticketId='+ ${ticketId!=null ? ticketId :''} + '&ticketName='+${ticketName !=null ? ticketName :''} + '&ticketPrice=' +${ticketPrice !=null ? ticketPrice :''}}"></a>
          <a class="next" th:href="@{'/ticket/list?page=' + ${nextPage} + '&ticketId='+ ${ticketId!=null ? ticketId :''} + '&ticketName='+${ticketName !=null ? ticketName :''} + '&ticketPrice=' +${ticketPrice !=null ? ticketPrice :''}}">&gt;&gt;</a>
        </div>
      </div>

    </div>
    <script>
        //删除界面
        function deldate(obj){
            //获取当前选中行用户的goodsId
            var ticketId = $(obj).parents("tr").find("td").eq(0).text();
            //调出弹出框
            layer.open({
                content: '请问您是否确定删除该信息？'
                ,btn: ['确定', '取消'],
                btnAlign: 'r',
                anim: 2
                ,yes: function(index, layero){
                    layer.close(index);
                    //发送ajaxj请求
                    $.ajax({
                        url: "/ticket/delTicket",//请求地址
                        type: "post",//请求方式
                        data: {"ticketId": ticketId},
                        dataType: "text",//返回的数据类型 :对象:json,字符串和数字:text
                        success:function (data) {
                            layer.alert("",{icon: 1});
                            setTimeout("window.location.reload();",500)
                        }
                    })
                }
                ,btn2: function(){}
            });
        }

        //修改界面
        function update(obj){
            //获取当前选中行用户的goodsId
            var ticketId = $(obj).parents("tr").find("td").eq(0).text();
            //打开窗体
            x_admin_show("修改页面","/ticket/toUpDataTicket?ticketId="+ticketId);
        }

    </script>
  </body>

</html>
